/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author mapxinh
 */
public class BillDetailsTableModel extends AbstractTableModel{
    String[] headers = {"ProductID", "Product Name", "Sell Price", "Quantity", "Sub Total"};
    List<BillDetails_BS> orderItems;
//    List<Bill_BS> order;

    public BillDetailsTableModel() {
        orderItems = new ArrayList<BillDetails_BS>();
    }

     public BillDetails_BS getProduct(int rowIndex) {
        return  orderItems.get(rowIndex);
    }
    

    public int getRowCount() {
        return orderItems.size();
    }

    public int getColumnCount() {
        return headers.length;
    }
 @Override
    public String getColumnName(int column) {
        return headers[column];
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        BillDetails_BS item = orderItems.get(rowIndex);

        switch (columnIndex) {
            case 0:
                return item.getPID();
            case 1:
                return item.getPName();
            case 2:
                return item.getBdSellPrice();
            case 3:
                return item.getBdQuantity();
            case 4:
                return item.getSubTotal();
        }

        return null;
    }
    public void addOrderItem(BillDetails_BS item) {
        orderItems.remove(item);
        orderItems.add(item);
        fireTableDataChanged();
    }
    public void removeOrder(BillDetails_BS pro) {
            orderItems.remove(pro);
            fireTableDataChanged();
        }

}
